import unittest

from parameterized import parameterized

from api.manager_user_api import Manager_user_api
from common.assertUtil import assertUtil
from common.read_data import read_manager_user_add_data, read_manage_user_delete_uid, read_manage_user_update_uid, \
    read_manage_user_reset_pwd


class TestManageUser(unittest.TestCase):
    # 用户添加

    @parameterized.expand(read_manager_user_add_data())
    @unittest.skip
    def test_user_add(self, desc, req_data, success, msg):
        resq = Manager_user_api.add_user(req_data)
        assertUtil(self, resq, success=success, msg=msg)

    # 用户管理查询
    def test_select_all(self):
        json_data = {
            "actualName": "",
            "isDelete": 0,
            "isDisabled": 0,
            "isExternal": 0,
            "keyword": "",
            "orders": [
                {
                    "asc": True,
                    "column": ""
                }
            ],
            "pageNum": 1,
            "pageSize": 10,
            "phone": "",
            "searchCount": False,
            "sourceId": 0,
            "userIds": []
        }
        resq = Manager_user_api.select_user_all(json_data)
        print(resq)
        assertUtil(self, resq, success=True, msg="操作成功")

    # 删除指定用户,id存在

    @parameterized.expand(read_manage_user_delete_uid())
    @unittest.skip
    def test_del_uid(self, desc, uid, success, msg):
        # print(read_manage_user_delete_uid())
        rsp = Manager_user_api.delete_user_Id(uid)
        assertUtil(self, rsp, success=success, msg=msg)
        print(desc)


    #更新用户
    @parameterized.expand(read_manage_user_update_uid())
    @unittest.skip
    def test_update_user(self,desc,req_data,success,msg):
        resp= Manager_user_api.update_user(req_data)
        assertUtil(self,resp,success,msg)

    ##用户重置密码
    @parameterized.expand(read_manage_user_reset_pwd())
    @unittest.skip
    def test_reset_pwd(self,desc,userId,success,msg):
        resp = Manager_user_api.update_user(userId)
        assertUtil(self, resp, success, msg)
